<template>
  <div :class="$style.wrap">
    <ContentWrap>
      <Query ref="query" @on-query="queryHandle"></Query>
      <div class="button-container" style="padding-top: 0">
        <Allege :selection-list="selectionList" @on-refresh="refreshTable('onPage')">申诉</Allege>
        <ExportPane :table-config="tableConfig" :data-source="selectionList" :query-data-fun="exportQuery" filename="质检结果查询与申诉" extension="xls">导出</ExportPane>
      </div>
      <table-box ref="table" no-request :table-config="tableConfig" :other-filters="otherFilters" :other-raw="otherRaw" :selected-arry.sync="selectionList" @selection-change="selectionChangeHandle">
        <el-table-column slot="before" type="index" align="center" label="序号" width="50"></el-table-column>
      </table-box>
    </ContentWrap>
  </div>
</template>
<script>
import ContentWrap from '@/components/ContentWrap'
import ExportPane from '@/components/ExportPane'
import Query from '../components/query'
import Allege from '../components/allege'
import { allegeStateList, smileStateList, allegeList, timeOutList, modelList, lelveList } from '../../common'
import { appCode, domainCode } from '@/api/dataDict'
export default {
  name: 'TaskResult',
  components: {
    ContentWrap,
    Query,
    ExportPane,
    Allege
  },
  data() {
    return {
      tableConfig: {
        interfacePath: '/call-center/api/v1/qualityCheckTask/page',
        hideFuncBar: true,
        sort: 'createTime',
        order: 'desc',
        setting: [
          {
            prop: 'projectName',
            label: '项目名称',
            minWidth: 120
          },
          {
            prop: 'taskCode',
            label: '任务编码',
            minWidth: 145,
            className: 'table-click-text',
            isButton: true,
            clickFun: v => {
              this.$router.push({ name: 'PreviewEvalScore', params: { id: v.id }})
            }
          },
          {
            prop: 'litigant',
            label: '受检人',
            minWidth: 120,
            formatData: v => {
              return `${v.litigantName}(${v.litigant})`
            }
          },
          {
            prop: 'isTimeout',
            label: '是否超时',
            minWidth: 120,
            formatData: v => {
              return this.$getNameByDataDict(v.isTimeout, timeOutList)
            }
          },
          {
            prop: 'score',
            label: '质检得分',
            minWidth: 100
          },
          {
            prop: 'executor',
            label: '质检人',
            minWidth: 120,
            formatData: v => {
              return `${v.executorName}(${v.executor})`
            }
          },
          {
            prop: 'isAppeal',
            label: '是否申诉',
            minWidth: 120,
            formatData: v => {
              return this.$getNameByDataDict(v.isAppeal, allegeList)
            }
          },
          {
            prop: 'appealState',
            label: '申诉处理状态',
            minWidth: 120,
            formatData: v => {
              return this.$getNameByDataDict(v.appealState, allegeStateList)
            }
          },
          {
            prop: 'appealScore',
            label: '申诉得分',
            minWidth: 100
          },
          {
            prop: 'isSmile',
            label: '是否微笑服务',
            minWidth: 120,
            formatData: v => {
              return this.$getNameByDataDict(v.isSmile, smileStateList)
            }
          },
          {
            prop: 'level',
            label: '等级',
            minWidth: 120,
            formatData: v => {
              return this.$getNameByDataDict(v.level, lelveList)
            }
          },
          {
            prop: 'typicalType',
            label: '标记典型',
            minWidth: 120,
            formatData: v => {
              return this.$getNameByDataDict(v.typicalType, modelList)
            }
          },
          {
            prop: 'callType',
            label: '呼叫类型',
            minWidth: 120,
            propEnum: {
              domainCode,
              appCode,
              dictTypeCode: 'CALL_TYPE'
            }
          },
          {
            prop: 'businessType1Name',
            label: '一级业务类型',
            minWidth: 120
          },
          {
            prop: 'businessType2Name',
            label: '二级业务类型',
            minWidth: 120
          }
        ]
      },
      otherFilters: [],
      otherRaw: {},
      selectionList: []
    }
  },
  methods: {
    queryHandle(otherFilters) {
      this.otherFilters = otherFilters
      this.refreshTable()
    },
    exportQuery(type) {
      return this.$refs.query.queryHandle(type)
    },
    selectionChangeHandle(v) {
      this.selectionList = v
    },
    // 刷新列表
    refreshTable(type) {
      this.$nextTick(() => {
        this.$refs.table.initTableData(type)
      })
    }
  }
}
</script>
<style lang='scss' module>
.warp{

}
</style>
